home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 320 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. Path: stdc.demon.co.uk!clive
  2. From: clive@stdc.demon.co.uk (Clive D.W. Feather)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Binary Mode stdin/stdout
  5. Date: Wed, 7 Feb 1996 06:24:30 GMT
  6. Organization: Demon Internet Limited (personal account)
  7. Message-ID: <DME74w.4M4@stdc.demon.co.uk>
  8. References: <4f67kg$11g@cortex.dialin.rrze.uni-erlangen.de>
  9. Reply-To: clive@demon.net
  10. X-NNTP-Posting-Host: stdc.demon.co.uk
  11.  
  12. In article <4f67kg$11g@cortex.dialin.rrze.uni-erlangen.de>,
  13. Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de> wrote:
  14. > Why isn't there a standard way of allowing an ISO C program to switch
  15. > the standard input and output into binary transparent mode (as with
  16. > the "b" flag in fopen()/freopen() for normal files)?
  17. >
  18. > Has this just been forgotten or is there a good technical reason?
  19.  
  20. On some implementations, this decision has to be made at the time you
  21. open the file and can't be changed. For example, on OS/360 and its
  22. successors, text files might be VB80, while binary files will be U508,
  23. or whatever. The former is stored as:
  24.  
  25.     <4 byte value N1> <N1 bytes of text forming a line>
  26.     <4 byte value N2> <N1 bytes of text forming a line>
  27.     <4 byte value N3> <N1 bytes of text forming a line>
  28.     ...
  29.  
  30. (note that there are no newline characters) and the latter as
  31.  
  32.     <4 byte value N1> <N1 bytes of data> <508-N1 bytes ignored>
  33.     <4 byte value N2> <N1 bytes of data> <508-N1 bytes ignored>
  34.     <4 byte value N3> <N1 bytes of data> <508-N1 bytes ignored>
  35.     ...
  36.  
  37. (data is read and written in 512 byte units). How do you switch these ?
  38.  
  39. -- 
  40. Clive D.W. Feather                       | If you lie to the compiler,
  41. cdwf@cityscape.co.uk   (work, preferred) | it will get its revenge.
  42. clive@stdc.demon.co.uk (home)            |   - Henry Spencer
  43.